package com.reden.enums;

import java.util.HashMap;
import java.util.LinkedList;
import java.util.List;
import java.util.Map;

public enum MonthEnum {
    JANUARY(1, "一月", "31"),
    FEBRUARY(2, "二月", "28,29"),
    MARCH(3, "三月", "31"),
    APRIL(4, "四月", "30"),
    MAY(5, "五月", "31"),
    JUNE(6, "六月", "30"),
    JULY(7, "七月", "31"),
    AUGUST(8, "八月", "31"),
    SEPTEMBER(9, "九月", "30"),
    OCTOBER(10, "十月", "31"),
    NOVEMBER(11, "十一月", "30"),
    DECEMBER(12, "十二月", "31"),
    ;

    private Integer value;
    private String label;
    private String remark;

    public Integer getValue() {
        return value;
    }

    public String getLabel() {
        return label;
    }

    public String getRemark() {
        return remark;
    }

    MonthEnum(Integer value, String label, String remark) {
        this.value = value;
        this.label = label;
        this.remark = remark;
    }

    public static List<Map> getEnumAll() {
        java.util.List<java.util.Map> result = new LinkedList<>();
        for (MonthEnum e : MonthEnum.values()) {
            java.util.Map<String, Object> map = new HashMap<>();
            map.put("name", e.name());
            map.put("value", e.getValue());
            map.put("label", e.getLabel());
            map.put("remark", e.getRemark());
            result.add(map);
        }
        return result;
    }

    public static MonthEnum getEnumByValue(Integer value) {
        if (value == null)
            return null;
        for (MonthEnum e : MonthEnum.values())
            if (value.equals(e.getValue()))
                return e;
        return null;
    }
}
